-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AOS-EMU2: Add contact,relay,outlet discovery; update yaml,snmprec,json #8317
Conversation
Hey guys, not sure what to do about the snmprec error. The same pre-commit parameters pass on my test box: https://p.libren.ms/view/a921acc6. |
array($state_index_id,'Normal',0,1,0) , | ||
array($state_index_id,'Alert',0,2,1) | ||
); | ||
foreach ($states as $value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is using old style state definitions.
Please see the documentation for an updated code style (or use yaml).
https://docs.librenms.org/Developing/Sensor-State-Support/
$index = $contact['emsInputContactStatusInputContactIndex']; | ||
$oid = '.1.3.6.1.4.1.318.1.1.10.3.14.1.1.3.' . $index; | ||
$descr = $contact['emsInputContactStatusInputContactName']; | ||
$currentstate = $contact['emsInputContactStatusInputContactState']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns a string when you use the mib, so you need to convert the string to a numeric value.
$state_index_id = create_state_index($state_name_nc); | ||
if ($state_index_id !== null) { | ||
$states = array( | ||
array($state_index_id,'Normal',0,1,0) , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the time it is better if you used the names returned by snmp instead of Normal and Alert. So: contactOpenEMS and contactClosedEMS. Or at least change the description to Open and Closed ( you can keep the inverted generic values so it correctly shows up as green or red)
mib_dir: | ||
- apc | ||
discovery: | ||
- sysObjectID: | ||
- .1.3.6.1.4.1.318.1.3.8.2 | ||
- .1.3.6.1.4.1.318.1.3.8.3 | ||
discovery_modules: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is kind of pointless and misleading to disable all these modules. Most don't do anything on your device.
While troubleshooting, I converted the states to the new format, here you go: $state_name_nc = 'emsInputContactNormalState_NC';
$states = array(
array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Open'),
array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
);
create_state_index($state_name_nc, $states); $state_name_no = 'emsInputContactNormalState_NO';
$states = array(
array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
);
create_state_index($state_name_no, $states); $state_name_nc = 'emsOutputRelayNormalState_NC';
$states = array(
array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
);
create_state_index($state_name_nc, $states); $state_name_no = 'emsOutputRelayNormalState_NO';
$states = array(
array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'Alert'),
array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Normal'),
);
create_state_index($state_name_no, $states); $state_name_on = 'emsOutletNormalState_ON';
$states = array(
array('value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'On'),
array('value' => 2, 'generic' => 1, 'graph' => 0, 'descr' => 'Off'),
);
create_state_index($state_name_on, $states); $state_name_off = 'emsOutletNormalState_OFF';
$states = array(
array('value' => 1, 'generic' => 1, 'graph' => 0, 'descr' => 'On'),
array('value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'Off'),
);
create_state_index($state_name_off, $states); Remember my suggestion to change the descriptions from Alert/Normal to the snmp name or Open/Closed. |
Thanks @murrant. I'll work on fixing this up tonight/tomorrow and incorporating your converted states above. Sorry for all the trouble, still learning over here. :-) |
No worries. I'd like to convert the existing ones so people have good source code to look at, but haven't had time and it's working mostly 😀 |
Let us know if you have any questions. |
@laf another one trying to insert strings into a numeric field in the database. |
Remove extra if/else statement Make test data more interesting.
3ac6044
to
2500251
Compare
The inspection completed: No new issues |
This thread has been automatically locked since there has not been any recent activity after it was closed. |
DO NOT DELETE THIS TEXT
Please note
Testers
If you would like to test this pull request then please run:
./scripts/github-apply <pr_id>
, i.e./scripts/github-apply 5926